package com.wn.controller;


import com.wn.annotation.RequireRoles;
import com.wn.idCard.IDCardUtil;
import com.wn.service.FileService;
import com.wn.utils.Rsp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("file")
public class FileController {

    @Autowired
    FileService fileService;


//    @RequireRoles(roles = {"admin","super_admin"},index = 2)
    @PostMapping("/uploadImage")
    public Rsp uploadImage(@RequestParam("image") MultipartFile image) throws Exception {
        System.out.println("-----------------------");
        byte[] bytes = image.getBytes();
        String idMsg = IDCardUtil.getIdMsg(bytes);
        log.debug(idMsg);

        return fileService.uploadImage(image);
    }



}
